feat: implement WASM network caching to skip 0DNS calls on refresh #1799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[FEAT] WASM: Implement Cached Initialization to Skip 0DNS Calls on Refresh
Summary
This PR introduces a caching mechanism for the WASM SDK to significantly improve initialization performance on page reloads. By storing network details (miners and sharders) in the browser's
localStorage, the SDK can now initialize instantly without making a network call to the 0DNS (block worker) server.Changes
Core Logic
WASM Layer
localStorageviasyscall/js.refresh(boolean) parameter.refreshis false, it attempts to load from cache; if the cache is empty orrefreshis true, it performs a standard network discovery and updates the cache.refreshparameter.Impact & Safety
How to Test
/networkendpoint. Verifyzcn_network_infois created inlocalStorage./networkcall is not made, and the SDK initializes successfully using the cache.sdk.init(..., true)from JS. Verify that the SDK bypasses the cache and hits the network.Checklist
localStoragecaching logic.refreshflag support.core/clientto skip redundant DNS calls.InitSDKpath.